﻿using System;
using SqlSugar;

namespace MengXunAppTool.Helper
{
    public class Sql3Helper
    {
        private ConnectionConfig connection = null;
        public SqlSugarClient db = null;
        public Sql3Helper()
        {
            //string SqlIP = "192.168.5.206";
            string SqlIP = "192.168.2.3";
            string database = "MESDB";
            string uid = "sa";
            string pwd = "8ik,9ol.";
            connection = new ConnectionConfig()
            {
                ConnectionString = "server='" + SqlIP + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            };
            db = new SqlSugarClient(connection);
        }
        public bool SqlCheck()
        {
            try
            {
                db.Open();
                db.Close();
                db.Dispose();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        #region MX_AppVerRecord
        [SugarTable("MX_AppVerRecord")]
        public class MX_AppVerRecord
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public int id { get; set; }
            public string Customer { get; set; }
            public string Product { get; set; }
            public string AppName { get; set; }
            public string Version { get; set; }
            public string Enable { get; set; }
            public string Login { get; set; }
            public string ReleaseUser { get; set; }
            public DateTime ReleaseTime { get; set; }
            public string ReleaseLog { get; set; }
            public string FtpPath { get; set; }
            public string LocalPath { get; set; }
            public string ExePath { get; set; }
            public string ConfigPathList { get; set; }
            public string CheckUser1 { get; set; }
            public string CheckUser2 { get; set; }
            public string CheckTime { get; set; }
            public string PushUser { get; set; }
        }
        #endregion
        #region MX_AppRunRecord
        [SugarTable("MX_AppRunRecord")]
        public class MX_AppRunRecord
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public int id { get; set; }
            public int Appid { get; set; }
            public string Customer { get; set; }
            public string Product { get; set; }
            public string AppName { get; set; }
            public string Version { get; set; }
            public DateTime RunTime { get; set; }
            public string IP { get; set; }
            public string User { get; set; }
        }
        #endregion
        #region t_DD_UserDetail
        [SugarTable("t_DD_UserDetail")]
        public class t_DD_UserDetail
        {
            public string userid { get; set; }
            public string username { get; set; }
            public bool isStudent { get; set; }
            public string jobnumber { get; set; }
            public string workPlace { get; set; }
            public string position { get; set; }
            public string companyName { get; set; }
            public DateTime updatetime { get; set; }
        }
        #endregion
        #region MX_AppUsers
        [SugarTable("MX_AppUsers")]
        public class MX_AppUsers
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public int id { get; set; }
            public string userid { get; set; }
            public string userName { get; set; }
            public string workPlace { get; set; }
        }
        #endregion
    }
}
